home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / PlayerPRO 4.5.1 / MADH Library 4.01 / Example.c < prev    next >
C/C++ Source or Header  |  1996-02-07  |  3KB  |  126 lines

  1. /********************************************************/
  2. /*
  3.     Player PRO 4.5.1 -- Music Driver EXAMPLE
  4.  
  5.     Library Version 4.01
  6.  
  7.     To use with Think C & CodeWarrior
  8.  
  9.     Antoine ROSSET
  10.     16 Tranchees
  11.     1206 GENEVA
  12.     SWITZERLAND
  13.     
  14.     FAX: (41 22) 346 11 97
  15.     PHONE: (41 89) 203 74 62
  16.     Compuserve: 100277,164
  17.     Internet: rosset@dial.eunet.ch
  18. */
  19. /********************************************************/
  20.  
  21. #include "RDriver.h"            // Mad Driver functions & globals
  22.  
  23. /*****************************/
  24. /****** MAIN FUNCTION ********/
  25. /*****************************/
  26.  
  27. void main( void)
  28. {
  29. Point            where = { -1, -1};
  30. SFReply            reply;
  31. SFTypeList        aType;
  32. Boolean            End;
  33.  
  34. /***************                    ****************/
  35. /******          Toolbox Initialization      **********/
  36. /***************                    ****************/
  37.  
  38. InitGraf( &qd.thePort);
  39. InitFonts();
  40. InitWindows();
  41. InitMenus();
  42. TEInit();
  43. InitDialogs(0L);
  44. InitCursor();
  45. MaxApplZone();
  46. MoreMasters();
  47.  
  48. /*******************************************************************************************/
  49. /****** MAD Library Initialisation : choose the best driver for the current hardware ******/
  50. /******                                                                                  ******/
  51. /****** Standard initialization with 4 channels...                                      ******/
  52. /*******************************************************************************************/
  53.  
  54. {
  55. MADDriverSettings    init;
  56.  
  57.  
  58. /*
  59. MANUAL DRIVER CONFIGURATION, by example:
  60.  
  61. init.numChn                = 4;
  62. init.outPutBits         = 8;
  63. init.outPutRate            = rate22khz;
  64. init.outPutMode            = StereoOutPut;
  65. init.driverMode            = SoundManagerDriver;
  66. init.antiAliasing        = false;
  67. init.repeatMusic        = false;
  68. init.Interpolation        = false;
  69. init.MicroDelay            = false;
  70. init.MicroDelaySize     = 0;
  71. init.surround             = false;
  72.  
  73. */
  74.  
  75. /* AUTOMATIC DRIVER CONFIGURATION FOR CURRENT MAC HARDWARE*/
  76. MADGetBestDriver( &init);
  77.  
  78. MADInitLibrary( "\pPlugs");
  79. if( MADCreateDriver( &init) != noErr) DebugStr("\pSmall Problem...");
  80. }
  81. /*********************************/
  82. /*********************************/
  83. /*********************************/
  84.  
  85. /****** Open a music file via Plugs ********/
  86. End = false;
  87.  
  88.  
  89.  
  90. while( End == false)
  91. {
  92.     FlushEvents( everyEvent, 0);
  93.     SFGetFile( where, "\p", 0L, -1, aType, 0L, &reply);
  94.     
  95.     if( !reply.good) End = true;
  96.     else
  97.     {
  98.         SetVol( 0L, reply.vRefNum);        
  99.         
  100.         if( MADPlugAvailable( reply.fType))        // Is available a plug to open this file?
  101.         {
  102.             if( MADImportMusicFile( reply.fType, reply.fName) == noErr)        // Load this music with help of Plugs
  103.                                                                             // in application folder or in 'Plugs' folder
  104.             {
  105.                 MADPlay();                        // Turn interrupt driver function ON
  106.                 MADDriver->Reading = true;        // Read the current partition in memory
  107.                 
  108.                 while( !Button())
  109.                 {
  110.                     /** Do what you want here....                    **/
  111.                     /** Bla bla...                                    **/
  112.                     /** By example:    Run your realtime 3D game...     **/
  113.                 }
  114.                 MADDriver->Reading = false;        // Stop reading current partition
  115.                 MADStop();                        // Stop driver interrupt function
  116.                 
  117.                 MADDisposeMusic();                // Dispose the current music
  118.             }
  119.         }
  120.     }
  121. }
  122. MADDisposeDriver();                        // Dispose music driver
  123. MADDisposeLibrary();                    // Close music library
  124.  
  125. FlushEvents( everyEvent, 0);
  126. }